﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace fileCombination
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button3_Click(object sender, EventArgs e)
        {
            string file1Content = File.ReadAllText(textBox1.Text);
            string file2Content = File.ReadAllText(textBox2.Text);

            // 创建新文件，将文件1和文件2的内容合并写入
            string dataDirectory = "D:\\c#\\fileCombination"+"//Data";
            Directory.CreateDirectory(dataDirectory);
            string combinedFilePath = Path.Combine(dataDirectory, "combined.txt");
            using (StreamWriter writer = new StreamWriter(combinedFilePath))
            {
                writer.Write(file1Content + file2Content);
            }

            MessageBox.Show("文件合并完成！");
        }
    

        private void button2_Click(object sender, EventArgs e)
        {
            openFileDialog1.RestoreDirectory = false;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox2.Text = openFileDialog1.FileName;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.RestoreDirectory = false;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
            }
        }

    }
}
